package com.itheima.d11_api_objects;

import java.util.Objects;

/*
    Objects是一个工具类，提供了很多操作对象的静态方法给我们使用。
        public static boolean equals(Object a, Object b)	先做非空判断，再比较两个对象
        public static boolean isNull(Object obj) 	判断对象是否为null，为null返回true ,反之
        public static boolean nonNull(Object obj) 	判断对象是否不为null，不为null则返回true, 反之
 */
public class Test {
    public static void main(String[] args) {
        Cat d1 = new Cat("大黄", 24);
        Cat d2 = new Cat("大黄", 24);
        System.out.println(d1.equals(d2));
        d1 = null;
        boolean equals = Objects.equals(d1, d2);
        System.out.println(equals);
        System.out.println(Objects.isNull(d1));
        System.out.println(Objects.isNull(d2));
        System.out.println(Objects.nonNull(d1));
        System.out.println(Objects.nonNull(d2));

        /**
         *  public static boolean equals(Object a, Object b) {
         *         return (a == b) || (a != null && a.equals(b));
         *     }
         */
    }
}
